package com.fg.cloud.manager.service.product.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.product.vo.ProductMoreUnitVo;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.product.ProductMoreUnitMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.product.ProductMoreUnitService;

/**
 * Description:多单位Service
 * @author around
 * @date 2017年8月18日下午2:06:03
 */
@Service
public class ProductMoreUnitServiceImpl extends BaseServiceImpl implements ProductMoreUnitService{
	
	@Autowired
	private ProductMoreUnitMapper moreUnitMapper; 

	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return moreUnitMapper;
	}

	@Override
	public List<ProductMoreUnitVo> findList(Long facId, Long skuId) {
		return moreUnitMapper.findList(facId, skuId);
	}
	
	@Override
	@Transactional
	public boolean insert(Long facId, Long skuId, List<ProductMoreUnitVo> moreUnitList) {
		deletesBySku(facId, skuId);
		return moreUnitMapper.batchInsert(facId, skuId, moreUnitList) > 0 ? true : false;
	}

	@Override
	@Transactional
	public boolean deletesBySku(Long facId, Long skuId) {
		return moreUnitMapper.batchDelete(facId, skuId) > 0 ? true : false;
	}

	@Override
	@Transactional
	public boolean deletesByProduct(Long facId, Long productId) {
		// TODO Auto-generated method stub
		return false;
	}


}
